
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>矩阵的压缩存储 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="广义表.html" />
    
    
    <link rel="prev" href="数组的定义.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    数据结构（C语言版） 复习总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第一章 绪论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter2/chapter2.html">
            
                <a href="../chapter2/chapter2.html">
            
                    
                    第二章 线性表
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter2/顺序表.html">
            
                <a href="../chapter2/顺序表.html">
            
                    
                    线性表的顺序表示和实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter2/链表.html">
            
                <a href="../chapter2/链表.html">
            
                    
                    线性表的链式表示和实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/chapter3.html">
            
                <a href="../chapter3/chapter3.html">
            
                    
                    第三章 栈和队列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/栈.html">
            
                <a href="../chapter3/栈.html">
            
                    
                    抽象数据类型栈的定义和实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/队列.html">
            
                <a href="../chapter3/队列.html">
            
                    
                    抽象数据类型队列的定义和实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    第四章 串
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter4/串类型.html">
            
                <a href="../chapter4/串类型.html">
            
                    
                    串类型的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter4/串的表示和实现.html">
            
                <a href="../chapter4/串的表示和实现.html">
            
                    
                    串的表示和实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter4/串的模式匹配算法.html">
            
                <a href="../chapter4/串的模式匹配算法.html">
            
                    
                    串的模式匹配算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    第五章 数组和广义表
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="数组的定义.html">
            
                <a href="数组的定义.html">
            
                    
                    数组的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.2" data-path="矩阵的压缩存储.html">
            
                <a href="矩阵的压缩存储.html">
            
                    
                    矩阵的压缩存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="广义表.html">
            
                <a href="广义表.html">
            
                    
                    广义表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    第六章 树和二叉树
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter6/树.html">
            
                <a href="../chapter6/树.html">
            
                    
                    树的定义与基本术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/二叉树.html">
            
                <a href="../chapter6/二叉树.html">
            
                    
                    二叉树
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.2.1" data-path="../chapter6/二叉树的二叉链表实现.html">
            
                <a href="../chapter6/二叉树的二叉链表实现.html">
            
                    
                    二叉树的二叉链表实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter6/遍历二叉树和线索二叉树.html">
            
                <a href="../chapter6/遍历二叉树和线索二叉树.html">
            
                    
                    遍历二叉树和线索二叉树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter6/树和森林.html">
            
                <a href="../chapter6/树和森林.html">
            
                    
                    树和森林
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter6/赫夫曼树.html">
            
                <a href="../chapter6/赫夫曼树.html">
            
                    
                    赫夫曼树
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                    第七章 图
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter7/图.html">
            
                <a href="../chapter7/图.html">
            
                    
                    图的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter7/图的存储结构.html">
            
                <a href="../chapter7/图的存储结构.html">
            
                    
                    图的存储结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter7/图的遍历.html">
            
                <a href="../chapter7/图的遍历.html">
            
                    
                    图的遍历
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter7/最小生成树.html">
            
                <a href="../chapter7/最小生成树.html">
            
                    
                    最小生成树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter7/有向无环图.html">
            
                <a href="../chapter7/有向无环图.html">
            
                    
                    有向无环图的应用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter8/查找.html">
            
                <a href="../chapter8/查找.html">
            
                    
                    第八章 查找
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter8/静态查找表.html">
            
                <a href="../chapter8/静态查找表.html">
            
                    
                    静态查找表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter8/动态查找表.html">
            
                <a href="../chapter8/动态查找表.html">
            
                    
                    动态查找表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter8/哈希表.html">
            
                <a href="../chapter8/哈希表.html">
            
                    
                    哈希表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter9/内部排序.html">
            
                <a href="../chapter9/内部排序.html">
            
                    
                    第九章 内部排序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter9/插入排序.html">
            
                <a href="../chapter9/插入排序.html">
            
                    
                    插入排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter9/选择排序.html">
            
                <a href="../chapter9/选择排序.html">
            
                    
                    选择排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter9/快速排序.html">
            
                <a href="../chapter9/快速排序.html">
            
                    
                    快速排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter9/归并排序和基数排序.html">
            
                <a href="../chapter9/归并排序和基数排序.html">
            
                    
                    归并排序和基数排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter9/排序方法的比较.html">
            
                <a href="../chapter9/排序方法的比较.html">
            
                    
                    排序方法的比较
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >矩阵的压缩存储</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x77E9;&#x9635;&#x7684;&#x538B;&#x7F29;&#x5B58;&#x50A8;">&#x77E9;&#x9635;&#x7684;&#x538B;&#x7F29;&#x5B58;&#x50A8;</h2>
<p>&#x5728;&#x6570;&#x503C;&#x5206;&#x6790;&#x4E2D;&#x7ECF;&#x5E38;&#x51FA;&#x73B0;&#x4E00;&#x4E9B;&#x9636;&#x6570;&#x5F88;&#x9AD8;&#x7684;&#x77E9;&#x9635;&#xFF0C;&#x540C;&#x65F6;&#x5728;&#x77E9;&#x9635;&#x4E2D;&#x7531;&#x8BB8;&#x591A;&#x503C;&#x76F8;&#x540C;&#x7684;&#x5143;&#x7D20;&#x6216;&#x8005;&#x662F;&#x96F6;&#x5143;&#x7D20;&#x3002;&#x4E3A;&#x4E86;&#x8282;&#x7701;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x5BF9;&#x8FD9;&#x4E9B;&#x77E9;&#x9635;&#x8FDB;&#x884C;<strong>&#x538B;&#x7F29;&#x5B58;&#x50A8;</strong>&#xFF1A;&#x4E3A;&#x591A;&#x4E2A;&#x503C;&#x76F8;&#x540C;&#x7684;&#x5143;&#x53EA;&#x5206;&#x914D;&#x4E00;&#x4E2A;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x5BF9;&#x96F6;&#x5143;&#x4E0D;&#x5206;&#x914D;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x3002;</p>
<blockquote>
<p>&#x6B64;&#x8282;&#x4E2D;&#x6240;&#x6709;&#x63D0;&#x5230;&#x7684;&#x77E9;&#x9635;&#x7684;&#x4E0B;&#x6807;&#x90FD;&#x662F;&#x4ECE; <strong>1</strong> &#x5F00;&#x59CB;&#x8BA1;&#x6570;&#x7684;&#x3002;</p>
</blockquote>
<h3 id="&#x7279;&#x6B8A;&#x77E9;&#x9635;">&#x7279;&#x6B8A;&#x77E9;&#x9635;</h3>
<p><strong>&#x7279;&#x6B8A;&#x77E9;&#x9635;</strong>&#x662F;&#x503C;&#x76F8;&#x540C;&#x7684;&#x5143;&#x7D20;&#x6216;&#x96F6;&#x5143;&#x7D20;&#x5728;&#x77E9;&#x9635;&#x4E2D;&#x7684;&#x5206;&#x5E03;&#x6709;&#x4E00;&#x5B9A;&#x89C4;&#x5F8B;&#x7684;&#x77E9;&#x9635;&#x3002;</p>
<ol>
<li><p><strong>&#x5BF9;&#x79F0;&#x77E9;&#x9635;</strong></p>
<p> &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4E3A;&#x6BCF;&#x4E00;&#x5BF9;&#x5BF9;&#x79F0;&#x5143;&#x5206;&#x914D;&#x4E00;&#x4E2A;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x5219;&#x53EF;&#x5C06; <em>n<sup>2</sup></em> &#x4E2A;&#x5143;&#x538B;&#x7F29;&#x5B58;&#x50A8;&#x5230; <em><code>n(n+1)/2</code></em> &#x4E2A;&#x5143;&#x7684;&#x7A7A;&#x95F4;&#x4E2D;&#x3002;</p>
<p> &#x5047;&#x8BBE;&#x4EE5;&#x4E00;&#x7EF4;&#x6570;&#x7EC4; <em><code>sa[n(n+1)/2]</code></em> &#x4F5C;&#x4E3A; n &#x9636;&#x5BF9;&#x79F0;&#x77E9;&#x9635; A &#x7684;&#x5B58;&#x50A8;&#x7ED3;&#x6784;&#xFF0C;&#x5219; <em><code>sa[k]</code></em> &#x548C;&#x77E9;&#x9635;&#x5143;&#x7D20; <em>a<sub>ij</sub></em> &#x4E4B;&#x95F4;&#x5B58;&#x5728;&#x7740;&#x4E00;&#x4E00;&#x5BF9;&#x5E94;&#x5173;&#x7CFB;&#xFF1A;</p>
 <center><img src="&#x5BF9;&#x79F0;&#x77E9;&#x9635;&#x538B;&#x7F29;&#x5B58;&#x50A8;&#x516C;&#x5F0F;.png"></center>

<p> &#x7531;&#x6B64;&#xFF0C;&#x79F0; <em><code>sa[n(n+1)/2]</code></em> &#x4E3A; n &#x9636;&#x5BF9;&#x79F0;&#x77E9;&#x9635; A &#x7684;&#x538B;&#x7F29;&#x5B58;&#x50A8;&#x3002;</p>
</li>
<li><p><strong>&#x4E09;&#x89D2;&#x77E9;&#x9635;</strong></p>
<p> &#x4E09;&#x89D2;&#x77E9;&#x9635;&#x662F;&#x6307;&#x77E9;&#x9635;&#x7684;&#x4E0A;&#xFF08;&#x4E0B;&#xFF09;&#x4E09;&#x89D2;&#x4E2D;&#x7684;&#x5143;&#x5747;&#x4E3A;&#x5E38;&#x6570; c &#x6216;&#x96F6;&#x7684; n &#x9636;&#x77E9;&#x9635;&#x3002;&#x5219;&#x9664;&#x4E86;&#x548C;&#x5BF9;&#x79F0;&#x77E9;&#x9635;&#x4E00;&#x6837;&#xFF0C;&#x53EA;&#x5B58;&#x50A8;&#x5176;&#x4E0A;&#xFF08;&#x4E0B;&#xFF09;&#x4E09;&#x89D2;&#x7684;&#x5143;&#x4E4B;&#x5916;&#xFF0C;&#x518D;&#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x5B58;&#x50A8;&#x5E38;&#x6570; c &#x7684;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x5373;&#x53EF;&#x3002;</p>
<p> &#x56E0;&#x6B64;&#x9700;&#x8981; <em><code>n(n+1)/2+1</code></em> &#x4E2A;&#x5B58;&#x50A8;&#x5355;&#x5143;&#xFF0C;&#x6309;&#x7167;&#x884C;&#x4F18;&#x5148;&#x65B9;&#x5F0F;&#x5B58;&#x5165;&#x6570;&#x7EC4; <em><code>sa[n(n+1)/2+1]</code></em> &#x4E2D;&#xFF0C;&#x5143;&#x7D20; <em>a<sub>ij</sub>(i&lt;=j)</em> &#x5728;&#x6570;&#x7EC4; <em><code>sa[k]</code></em> &#x4E2D;&#x7684;&#x4E0B;&#x6807;&#x4E3A; <em><code>k=(i-1)(2n-i+2)/2+j-1</code></em>&#x3002;</p>
</li>
<li><p><strong>&#x5BF9;&#x89D2;&#x77E9;&#x9635;</strong></p>
<p> &#x5BF9;&#x89D2;&#x77E9;&#x9635;&#x9664;&#x4E86;&#x4E3B;&#x5BF9;&#x89D2;&#x7EBF;&#x4E0A;&#x548C;&#x76F4;&#x63A5;&#x5728;&#x5BF9;&#x89D2;&#x7EBF;&#x4E0A;&#x3001;&#x4E0B;&#x82E5;&#x5E72;&#x6761;&#x5BF9;&#x89D2;&#x7EBF;&#x4E0A;&#x7684;&#x5143;&#x4E4B;&#x5916;&#xFF0C;&#x6240;&#x6709;&#x5176;&#x4ED6;&#x7684;&#x5143;&#x7D20;&#x7686;&#x4E3A;&#x96F6;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x975E;&#x96F6;&#x5143;&#x7D20;&#x6309;&#x884C;&#x5B58;&#x50A8;&#x5230;&#x4E00;&#x7EF4;&#x6570;&#x7EC4;&#x4E2D;&#xFF0C;&#x5143;&#x7D20; <em>a<sub>ij</sub>(i&gt;=j)</em> &#x5728;&#x4E00;&#x7EF4;&#x6570;&#x7EC4; <em><code>sa[k]</code></em> &#x4E2D;&#x7684;&#x4E0B;&#x6807;&#x4E3A; <em><code>k=2i+j-3</code></em>&#x3002;</p>
</li>
</ol>
<h3 id="&#x7A00;&#x758F;&#x77E9;&#x9635;">&#x7A00;&#x758F;&#x77E9;&#x9635;</h3>
<p>&#x5047;&#x8BBE;&#x5728; <em>m&#xD7;n</em> &#x7684;&#x77E9;&#x9635;&#x4E2D;&#xFF0C;&#x6709; t &#x4E2A;&#x5143;&#x7D20;&#x4E0D;&#x4E3A;&#x96F6;&#x3002;&#x4EE4; <em>`w=t/(m</em>n)<code>*&#xFF0C;&#x79F0; w &#x4E3A;&#x77E9;&#x9635;&#x7684;**&#x7A00;&#x758F;&#x56E0;&#x5B50;**&#x3002;&#x901A;&#x5E38;&#x8BA4;&#x4E3A; *</code>w&lt;=0.05`* &#x65F6;&#x79F0;&#x4E3A;&#x7A00;&#x758F;&#x77E9;&#x9635;&#x3002;</p>
<p>&#x5728;&#x5B58;&#x50A8;&#x7A00;&#x758F;&#x77E9;&#x9635;&#x65F6;&#xFF0C;&#x4E0D;&#x4EC5;&#x9700;&#x8981;&#x5B58;&#x50A8;&#x975E;&#x96F6;&#x5143;&#x7684;&#x503C;&#xFF0C;&#x8FD8;&#x5FC5;&#x987B;&#x540C;&#x65F6;&#x8BB0;&#x4F4F;&#x5B83;&#x6240;&#x5728;&#x7684;&#x884C;&#x548C;&#x5217;&#x7684;&#x4F4D;&#x7F6E; <em>(i,j)</em>&#xFF0C;&#x56E0;&#x6B64;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x4E09;&#x5143;&#x7EC4; <em><code>(i,j,a)</code></em> &#x552F;&#x4E00;&#x786E;&#x5B9A;&#x4E86;&#x77E9;&#x9635; A &#x7684;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x3002;</p>
<h4 id="&#x7A00;&#x758F;&#x77E9;&#x9635;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x987A;&#x5E8F;&#x8868;&#x5B58;&#x50A8;&#x8868;&#x793A;&#xFF1A;">&#x7A00;&#x758F;&#x77E9;&#x9635;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x987A;&#x5E8F;&#x8868;&#x5B58;&#x50A8;&#x8868;&#x793A;&#xFF1A;</h4>
<pre><code class="lang-C"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> MAXSIZE 100 <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;&#x7684;&#x6700;&#x5927;&#x503C;&#x4E3A; 100</span></span>

<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span>
{
    <span class="hljs-keyword">int</span> i,j; <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x7684;&#x884C;&#x4E0B;&#x6807;&#x4E0E;&#x5217;&#x4E0B;&#x6807;</span>
    ElemType e; <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x7684;&#x503C;</span>
}Triple;

<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span>
{
    Triple data[MAXSIZE+<span class="hljs-number">1</span>]; <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x4E09;&#x5143;&#x7EC4;&#xFF0C;data[0] &#x8868;&#x793A;&#x672A;&#x4F7F;&#x7528;</span>
    <span class="hljs-keyword">int</span> mu, nu, tu; <span class="hljs-comment">// &#x77E9;&#x9635;&#x7684;&#x884C;&#x6570;&#x3001;&#x5217;&#x6570;&#x3001;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;</span>
}TSMatrix;
</code></pre>
<blockquote>
<p>data &#x57DF;&#x4E2D;&#x8868;&#x793A;&#x975E;&#x96F6;&#x5143;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x662F;&#x4EE5;&#x884C;&#x5E8F;&#x4E3A;&#x4E3B;&#x5E8F;&#x987A;&#x5E8F;&#x6392;&#x5217;&#x7684;&#x3002;</p>
</blockquote>
<p>&#x5047;&#x8BBE; a &#x548C; b &#x662F; TSMatrix &#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5206;&#x522B;&#x8868;&#x793A;&#x77E9;&#x9635; M &#x548C; T&#xFF08;&#x4E24;&#x8005;&#x4E92;&#x4E3A;&#x8F6C;&#x7F6E;&#x77E9;&#x9635;&#xFF09;&#xFF0C;&#x7531; a &#x5F97;&#x5230; b &#x53EA;&#x8981;&#x505A;&#x5230;&#xFF1A;</p>
<ul>
<li>&#x5C06;&#x77E9;&#x9635;&#x884C;&#x3001;&#x5217;&#x503C;&#x76F8;&#x4E92;&#x4EA4;&#x6362;&#xFF1B;</li>
<li>&#x5C06;&#x6BCF;&#x4E2A;&#x4E09;&#x5143;&#x7EC4;&#x4E2D;&#x7684; <em>i</em> &#x548C; <em>j</em> &#x76F8;&#x4E92;&#x8C03;&#x6362;&#xFF1B;</li>
<li>&#x91CD;&#x6392;&#x4E09;&#x5143;&#x7EC4;&#x4E4B;&#x95F4;&#x7684;&#x6B21;&#x5E8F;&#xFF0C;&#x4F7F;&#x65B0;&#x4E09;&#x5143;&#x7EC4;&#x4EE5;&#x884C;&#x5E8F;&#x4E3A;&#x4E3B;&#x5E8F;&#x3002;</li>
</ul>
<blockquote>
<p>&#x5982;&#x4F55;&#x4F7F; b.data &#x4E2D;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x662F;&#x4EE5; T &#x7684;&#x884C;&#x4E3A;&#x4E3B;&#x5E8F;&#x4F9D;&#x6B21;&#x6392;&#x5217;&#x5462;&#xFF1F;</p>
<p>&#x6709;&#x4E24;&#x79CD;&#x5904;&#x7406;&#x65B9;&#x6CD5;&#xFF1A;</p>
<ol>
<li><p>&#x6309;&#x77E9;&#x9635;&#x7684;&#x5217;&#x5E8F;&#x8F6C;&#x7F6E;</p>
<p> &#x5373;&#x6309;&#x5217;&#x503C;&#x9012;&#x589E;&#x7684;&#x6B21;&#x5E8F;&#x4F9D;&#x6B21;&#x5728; a.data &#x4E2D;&#x627E;&#x5230;&#x76F8;&#x5E94;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x5E76;&#x4F9D;&#x6B21;&#x653E;&#x5165; b.data &#x4E2D;&#x3002;&#x5373;&#x627E;&#x5230; M &#x4E2D;&#x6BCF;&#x4E00;&#x5217;&#x6240;&#x6709;&#x975E;&#x96F6;&#x5143;&#x7D20;&#xFF0C;&#x9700;&#x5BF9;&#x5176;&#x4E09;&#x5143;&#x7EC4;&#x8868; a.data &#x4ECE;&#x7B2C;&#x4E00;&#x884C;&#x8D77;&#x626B;&#x63CF;&#x4E00;&#x904D;&#x3002;</p>
</li>
<li><p>&#x5FEB;&#x901F;&#x8F6C;&#x7F6E;</p>
<p> &#x6309; a.data &#x4E2D;&#x4E09;&#x5143;&#x7EC4;&#x6B21;&#x5E8F;&#x8FDB;&#x884C;&#x8F6C;&#x7F6E;&#xFF0C;&#x5E76;&#x5C06;&#x8F6C;&#x7F6E;&#x540E;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x653E;&#x5165; b &#x4E2D;&#x7684;&#x6070;&#x5F53;&#x4F4D;&#x7F6E;&#x3002;&#x9700;&#x8981;&#x9884;&#x5148;&#x786E;&#x5B9A; M &#x4E2D;&#x6BCF;&#x4E00;&#x5217;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x5728; b.data &#x4E2D;&#x7684;&#x4F4D;&#x7F6E;&#x3002;&#x4E3A;&#x786E;&#x5B9A;&#x8FD9;&#x4E9B;&#x4F4D;&#x7F6E;&#xFF0C;&#x8F6C;&#x7F6E;&#x524D;&#xFF0C;&#x5E94;&#x5148;&#x6C42;&#x5F97; M &#x7684;&#x6BCF;&#x4E00;&#x5217;&#x4E2D;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;&#xFF0C;&#x8FDB;&#x800C;&#x6C42;&#x6BCF;&#x4E00;&#x5217;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x5728; b.data &#x4E2D;&#x5E94;&#x6709;&#x7684;&#x4F4D;&#x7F6E;&#x3002; </p>
<h4 id="&#x884C;&#x903B;&#x8F91;&#x94FE;&#x63A5;&#x7684;&#x987A;&#x5E8F;&#x8868;">&#x884C;&#x903B;&#x8F91;&#x94FE;&#x63A5;&#x7684;&#x987A;&#x5E8F;&#x8868;</h4>
</li>
</ol>
</blockquote>
<p>&#x4E3A;&#x4E86;&#x4FBF;&#x4E8E;&#x968F;&#x673A;&#x5B58;&#x53D6;&#x4EFB;&#x610F;&#x4E00;&#x884C;&#x7684;&#x975E;&#x96F6;&#x5143;&#xFF0C;&#x9700;&#x8981;&#x77E5;&#x9053;&#x6BCF;&#x4E00;&#x884C;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x5728;&#x4E09;&#x5143;&#x7EC4;&#x8868;&#x4E2D;&#x7684;&#x4F4D;&#x7F6E;&#x3002;&#x56E0;&#x6B64;&#x5C06;&#x5FEB;&#x901F;&#x8F6C;&#x7F6E;&#x7B97;&#x6CD5;&#x4E2D;&#x6307;&#x793A;&#x201C;&#x884C;&#x201D;&#x4FE1;&#x606F;&#x7684;&#x8F85;&#x52A9;&#x6570;&#x7EC4;&#x56FA;&#x5B9A;&#x5728;&#x7A00;&#x758F;&#x77E9;&#x9635;&#x7684;&#x5B58;&#x50A8;&#x7ED3;&#x6784;&#x4E2D;&#xFF0C;&#x8FD9;&#x79CD;&#x201C;&#x5E26;&#x884C;&#x94FE;&#x63A5;&#x4FE1;&#x606F;&#x201D;&#x7684;&#x4E09;&#x5143;&#x7EC4;&#x8868;&#x5373;&#x79F0;&#x4E3A;<strong>&#x884C;&#x903B;&#x8F91;&#x94FE;&#x63A5;&#x7684;&#x987A;&#x5E8F;&#x8868;</strong>&#x3002;</p>
<pre><code class="lang-C"><span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> MAXRC 10 <span class="hljs-comment">// &#x5047;&#x8BBE;&#x77E9;&#x9635;&#x884C;&#x6570;&#x7684;&#x6700;&#x5927;&#x503C;&#x4E3A; 10</span></span>

<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span>
{
    Triple data[MAXSIZE+<span class="hljs-number">1</span>]; <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x4E09;&#x5143;&#x7EC4;&#x8868;</span>
    <span class="hljs-keyword">int</span> rpos[MAXRC+<span class="hljs-number">1</span>]; <span class="hljs-comment">// &#x5404;&#x884C;&#x7B2C;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x7684;&#x4F4D;&#x7F6E;&#x8868;</span>
    <span class="hljs-keyword">int</span> mu, nu, tu; <span class="hljs-comment">// &#x77E9;&#x9635;&#x7684;&#x884C;&#x6570;&#x3001;&#x5217;&#x6570;&#x3001;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;</span>
}RLSMatrix;
</code></pre>
<h4 id="&#x5341;&#x5B57;&#x94FE;&#x8868;">&#x5341;&#x5B57;&#x94FE;&#x8868;</h4>
<p>&#x5F53;&#x77E9;&#x9635;&#x7684;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;&#x548C;&#x4F4D;&#x7F6E;&#x5728;&#x64CD;&#x4F5C;&#x8FC7;&#x7A0B;&#x4E2D;&#x53D8;&#x5316;&#x8F83;&#x5927;&#x65F6;&#xFF08;&#x5982;&#x77E9;&#x9635;&#x76F8;&#x52A0;&#xFF0C;&#x7531;&#x4E8E;&#x975E;&#x96F6;&#x5143;&#x7684;&#x63D2;&#x5165;&#x548C;&#x5220;&#x9664;&#x5C06;&#x4F1A;&#x5F15;&#x8D77;&#x4E09;&#x5143;&#x7EC4;&#x8868;&#x7684;&#x79FB;&#x52A8;&#xFF09;&#xFF0C;&#x8FD9;&#x65F6;&#x5E94;&#x8BE5;&#x91C7;&#x7528;&#x94FE;&#x5F0F;&#x5B58;&#x50A8;&#x7ED3;&#x6784;&#xFF0C;&#x8BBE;&#x884C;&#x6307;&#x9488;&#x6570;&#x7EC4;&#x548C;&#x5217;&#x6307;&#x9488;&#x6570;&#x7EC4;&#xFF0C;&#x5206;&#x522B;&#x6307;&#x5411;&#x6BCF;&#x884C;&#x3001;&#x5217;&#x7B2C;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#xFF0C;&#x6784;&#x6210;<strong>&#x5341;&#x5B57;&#x94FE;&#x8868;</strong>&#x3002;</p>
<p>&#x5728;&#x5341;&#x5B57;&#x94FE;&#x8868;&#x4E2D;&#xFF0C;&#x6BCF;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x53EF;&#x7528;&#x4E00;&#x4E2A;&#x542B; 5 &#x4E2A;&#x57DF;&#x7684;&#x7ED3;&#x70B9;&#x8868;&#x793A;&#xFF0C;&#x5176;&#x4E2D; <em>i</em>&#xFF0C;<em>j</em> &#x548C; <em>e</em> &#x8FD9;&#x4E09;&#x4E2A;&#x57DF;&#x5206;&#x522B;&#x8868;&#x793A;&#x8BE5;&#x975E;&#x96F6;&#x5143;&#x6240;&#x5728;&#x7684;&#x884C;&#x3001;&#x5217;&#x548C;&#x975E;&#x96F6;&#x5143;&#x7684;&#x503C;&#xFF0C;&#x5411;&#x53F3;&#x57DF; <code>right</code> &#x7528;&#x4EE5;&#x94FE;&#x63A5;&#x540C;&#x4E00;&#x884C;&#x4E2D;&#x4E0B;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#xFF0C;&#x5411;&#x4E0B;&#x57DF; <code>down</code> &#x7528;&#x4EE5;&#x94FE;&#x63A5;&#x540C;&#x4E00;&#x5217;&#x4E2D;&#x4E0B;&#x4E00;&#x4E2A;&#x975E;&#x96F6;&#x5143;&#x3002;&#x53EF;&#x7528;&#x4E24;&#x4E2A;&#x5206;&#x522B;&#x5B58;&#x50A8;&#x884C;&#x94FE;&#x8868;&#x548C;&#x5217;&#x94FE;&#x8868;&#x7684;&#x5934;&#x6307;&#x9488;&#x8868;&#x793A;&#x5341;&#x5B57;&#x94FE;&#x8868;&#x3002;</p>
<pre><code class="lang-C"><span class="hljs-comment">/**
 * &#x5341;&#x5B57;&#x94FE;&#x8868;&#x7684;&#x7ED3;&#x70B9;
 */</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> OLNode
{
    <span class="hljs-keyword">int</span> i,j; <span class="hljs-comment">// &#x8BE5;&#x975E;&#x96F6;&#x5143;&#x7684;&#x884C;&#x548C;&#x5217;&#x4E0B;&#x6807;</span>
    ElemType e; <span class="hljs-comment">// &#x975E;&#x96F6;&#x5143;&#x7D20;&#x503C;</span>
    <span class="hljs-keyword">struct</span> OLNode *right, *down; <span class="hljs-comment">// &#x8BE5;&#x975E;&#x96F6;&#x5143;&#x6240;&#x5728;&#x884C;&#x8868;&#x548C;&#x5217;&#x8868;&#x7684;&#x540E;&#x7EE7;&#x94FE;&#x57DF;</span>
}OLNode, *OLink;

<span class="hljs-comment">/**
 * &#x5341;&#x5B57;&#x94FE;&#x8868;
 */</span>
 <span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span>
{
    OLink *rhead, *chead; <span class="hljs-comment">// &#x884C;&#x548C;&#x5217;&#x94FE;&#x8868;&#x5934;&#x6307;&#x9488;&#x5411;&#x91CF;&#x57FA;&#x5740;,&#x7531; creatSMatrix() &#x5206;&#x914D;</span>
    <span class="hljs-keyword">int</span> mu,nu,tu; <span class="hljs-comment">// &#x7A00;&#x758F;&#x77E9;&#x9635;&#x7684;&#x884C;&#x6570;&#x3001;&#x5217;&#x6570;&#x548C;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;</span>
 }CrossList;

<span class="hljs-comment">/**
 * &#x521B;&#x5EFA;&#x5341;&#x5B57;&#x94FE;&#x8868;
 * m&#x3001;n&#x3001;t&#x5206;&#x522B;&#x8868;&#x793A; M &#x7684;&#x884C;&#x6570;&#x3001;&#x5217;&#x6570;&#x3001;&#x975E;&#x96F6;&#x5143;&#x4E2A;&#x6570;
 */</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">creatSMatrix</span><span class="hljs-params">(CrossList &amp;M, <span class="hljs-keyword">int</span> m, <span class="hljs-keyword">int</span> n, <span class="hljs-keyword">int</span> t)</span>
</span>{
    <span class="hljs-keyword">if</span> (M)
    {
        <span class="hljs-built_in">free</span>(M);
    }
    M.mu = m;
    M.nu = n;
    M.tu = t;
    <span class="hljs-keyword">if</span> (!(M.rhead = (OLink *) <span class="hljs-built_in">malloc</span>((m+<span class="hljs-number">1</span>) * <span class="hljs-keyword">sizeof</span>(OLink))))
    {
        <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;ERROR\n&quot;</span>);
        <span class="hljs-built_in">exit</span>(<span class="hljs-number">-1</span>);
    }
    <span class="hljs-keyword">if</span> (!(M.chead = (OLink *) <span class="hljs-built_in">malloc</span>((n+<span class="hljs-number">1</span>) * <span class="hljs-keyword">sizeof</span>(OLink))))
    {
        <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;ERROR\n&quot;</span>);
        <span class="hljs-built_in">exit</span>(<span class="hljs-number">-1</span>);
    }
    M.rhead[] = M.chead = <span class="hljs-literal">NULL</span>; <span class="hljs-comment">// &#x521D;&#x59CB;&#x5316;&#x884C;&#x5217;&#x5934;&#x6307;&#x9488;&#xFF0C;&#x5404;&#x884C;&#x5217;&#x94FE;&#x8868;&#x4E3A;&#x7A7A;&#x94FE;&#x8868;</span>
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="数组的定义.html" class="navigation navigation-prev " aria-label="Previous page: 数组的定义">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="广义表.html" class="navigation navigation-next " aria-label="Next page: 广义表">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"矩阵的压缩存储","level":"1.6.2","depth":2,"next":{"title":"广义表","level":"1.6.3","depth":2,"path":"chapter5/广义表.md","ref":"chapter5/广义表.md","articles":[]},"previous":{"title":"数组的定义","level":"1.6.1","depth":2,"path":"chapter5/数组的定义.md","ref":"chapter5/数组的定义.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter5/矩阵的压缩存储.md","mtime":"2018-08-20T13:49:58.145Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-02T10:05:33.540Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

